<div class="row">
	<br/>
	<div class="col-md-12">
        <table class="table table-striped table-hover" style="margin-top: 0px;word-break:break-all; word-wrap:break-all;">
		        <colgroup>
					<col width="50px">
					<col width="300px">
					<col width="150px">
					<col width="80px">
					<col width="60px">
					<col width="50px">
					<col width="160px">
					<col>
				</colgroup>
                <thead>
	                <tr>
	                	<td>序号</td>
	                    <td>消费者(consumer group)</td>
	                    <td data-toggle="tooltip" title="谁持有这个消费者">归属于</td>
	                    <td data-toggle="tooltip" title="集群模式：所有的消费者均分消息进行消费； 广播模式：每个消费者会消费所有消息">消费模式</td>
	                    <td data-toggle="tooltip" title="消费者未消费的消息数量">堆积量</td>
	                    <td data-toggle="tooltip">TPS</td>
	                    <td data-toggle="tooltip" title="所有队列中的最小更新时间">更新时间</td>
	                    <td>操作</td>
	                </tr>
                </thead>
                <tbody>
	                <#if response.empty && resultExt.empty>
					     <tr>
		                    <td colspan=8 align="center">
		                    	暂无数据
		                    </td>
		                <tr>
					<#else>
						<#list response.result as consumerProgressVO>
							<tr>
								<td>${consumerProgressVO_index + 1}</td>
		                    	<td><a style="cursor:pointer" title="查看消费详情" data-target="#consumeDetailModel${consumerProgressVO_index}" data-toggle="modal" <#if consumerProgressVO.minLastTimestamp gt 0 && consumerProgressVO.minLastTimestamp lt long.MAX_VALUE>onclick="getQueueOwner('${consumerProgressVO.consumer.name}', '${consumerProgressVO.consumer.id}')"</#if>>${consumerProgressVO.consumer.name}</a></td>
		                    	<#if consumerProgressVO.ownerList??>
		                    		<td>
			                    		<#if consumerProgressVO.ownerList?seq_contains(userInfo.user) || userInfo.user.type == 1>
					                    		<#list consumerProgressVO.ownerList as user>
										    		<span onclick="prepareDeleteUserConsumer(${user.id},'${user.name!user.getEmailName()}',${consumerProgressVO.consumer.id})" data-toggle="tooltip" title="移除${user.name!user.getEmailName()}?" class="producer_delete pointer">${user.name!user.getEmailName()}</span>
							                    	<#if user_index + 1 lt consumerProgressVO.ownerList?size>
							                    		,
							                    	</#if>
					                    		</#list>
			                    				<span class="glyphicon glyphicon-plus-sign pointer" data-toggle="tooltip" title="授权其他用户查看${consumerProgressVO.consumer.name}?" onclick="associateUserConsumer(${consumerProgressVO.consumer.id},'${consumerProgressVO.consumer.name}')"></span>
			                    		<#else>
			                    				<#list consumerProgressVO.ownerList as user>
										    		<span class="pointer">${user.name!user.getEmailName()}</span>
							                    	<#if user_index + 1 lt consumerProgressVO.ownerList?size>
							                    		,
							                    	</#if>
					                    		</#list>
			                    		</#if>  		
		                    		</td>
		                    	<#else>
		                    		<td>暂无</td>
		                    	</#if>
	                    		<td>集群消费</td>
	                    		<td>${consumerProgressVO.diff}</td>
	                    		<td>${consumerProgressVO.consumeTpsFormat}</td>
	                    		<#if consumerProgressVO.minLastTimestamp == 0>
	                    			<td>暂无</td>
	                    		<#else>
	                    			<#if consumerProgressVO.minLastTimestamp == long.MAX_VALUE>
	                    				<td>消费进度不存在</td>
	                    			<#else>
			                    		<td>${consumerProgressVO.minLastTimestamp?number_to_datetime?string("yyyy-MM-dd HH:mm:ss")}</td>
	                    			</#if>
	                    		</#if>
		                    	<td>
		                    		<#if consumerProgressVO.offsetMap??>
<!-- 		                    		<button type="button" class="btn btn-info" data-target="#consumeDetailModel${consumerProgressVO_index}" data-toggle="modal">详情</button>&nbsp; -->
		                    		<button title="跳过堆积的消息，直接消费至最新的消息" type="button" class="btn btn-success" data-target="#skipAccumulationModel${consumerProgressVO_index}" data-toggle="modal">跳过堆积</button>&nbsp;
		                    		<button title="消费过去一段时间至现在的消息" type="button" class="btn btn-success" data-target="#resetOffSetModel${consumerProgressVO_index}" data-toggle="modal">消息回溯</button>&nbsp;
		                    		</#if>
		                    		<button type="button" class="btn btn-warning" data-target="#deleteConsumerModel${consumerProgressVO_index}" data-toggle="modal"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></button>&nbsp;
		                    		
		                    		<#if consumerProgressVO.offsetMap??>
		                    		<!-- 详情 -->
		                    		<div id="consumeDetailModel${consumerProgressVO_index}" class="modal fade" tabindex="-1" aria-hidden="true">
										<div class="modal-dialog" style="width:700px">
											<div class="modal-content">
												<div class="modal-header">
													<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
													<h4 class="modal-title"><b>${consumerProgressVO.consumer.name}</b> 消费详情</h4>
												</div>
												<#if consumerProgressVO.dlqTopic?? && consumerProgressVO.dlqOffsetMap??>
													<table class="table table-striped table-hover" style="margin-top: 0px">
														<thead>
															<tr>
																<td class="warning" colspan=7>死消息Topic：<b style="color:red" data-toggle="tooltip" 
																title="消费失败达到最大重试次数(16)后，将会进入此topic，不再重试">${consumerProgressVO.dlqTopic}</b>
																	&nbsp;&nbsp;&nbsp;<span title="搜索死消息" class="glyphicon glyphicon-search" style="cursor:pointer;" 
																	onclick="initOffsetMsgModal('dlq', ${consumerProgressVO_index}, '${consumerProgressVO.dlqTopic}','${consumerProgressVO.dlqMaxOffset?c}')" data-target="#offsetMsgSearchModal" data-toggle="modal"></span>
																</td>
															</tr>
															<tr>
																<td>broker</td>
																<td>队列</td>
																<td>最小偏移量</td>
																<td>最大偏移量</td>
																<td>消息量</td>
																<td>更新时间</td>
															</tr>
														</thead>
														<tbody>
															<#list consumerProgressVO.dlqOffsetMap as k, v>
																<tr>
																	<td>${k.brokerName}</td>
																	<td>${k.queueId}</td>
																	<td>
																		${v.minOffset?string(",###")}
																	</td>
																	<td>
																		${v.maxOffset?string(",###")}
																	</td>
																	<td>
																		${v.maxOffset - v.minOffset}
																	</td>
																	<#if v.lastUpdateTimestamp <= 0>
										                    			<td data-toggle='tooltip' title="可能消息被删了">暂无</td>
										                    		<#else>
																		<td>
																			${v.lastUpdateTimestamp?number_to_datetime?string("yyyy-MM-dd HH:mm:ss")}
																		</td>
																	</#if>
																</tr>
															</#list>
														</tbody>
													</table>
												</#if>
												<#if consumerProgressVO.retryTopic?? && consumerProgressVO.retryOffsetMap??>
													<table class="table table-striped table-hover" style="margin-top: 0px">
														<thead>
															<tr>
																<td class="warning" colspan=7>重试Topic：<b style="color:red" data-toggle="tooltip" 
																title="消费失败的消息，会重新发回到此topic，以便重试消费">${consumerProgressVO.retryTopic}</b>
																&nbsp;&nbsp;&nbsp;<span title="搜索重试消息" class="glyphicon glyphicon-search" style="cursor:pointer;" 
																onclick="initOffsetMsgModal('retry', ${consumerProgressVO_index}, '${consumerProgressVO.retryTopic}','${consumerProgressVO.retryMaxOffset?c}')" data-target="#offsetMsgSearchModal" data-toggle="modal"></span>
																</td>
															</tr>
															<tr>
																<td>broker</td>
																<td>队列</td>
																<td>broker偏移量</td>
																<td>消费者偏移量</td>
																<td>堆积量</td>
																<td>消费到</td>
															</tr>
														</thead>
														<tbody>
															<#list consumerProgressVO.retryOffsetMap as k, v>
																<tr>
																	<td>${k.brokerName}</td>
																	<td>${k.queueId}</td>
																	<td>
																		${v.brokerOffset?string(",###")}
																	</td>
																	<td>
																		${v.consumerOffset?string(",###")}
																	</td>
																	<td>
																		${v.brokerOffset - v.consumerOffset}
																	</td>
																	<#if v.lastTimestamp <= 0>
										                    			<td data-toggle='tooltip' title="可能消息被删了">暂无</td>
										                    		<#else>
																		<td>
																			${v.lastTimestamp?number_to_datetime?string("yyyy-MM-dd HH:mm:ss")}
																		</td>
																	</#if>
																</tr>
															</#list>
														</tbody>
													</table>
												</#if>
												<table class="table table-striped table-hover" style="margin-top: 0px">
													<thead>
														<tr>
															<td class="warning" colspan=7>Topic：<b>${consumerProgressVO.topic}</td>
														</tr>
														<tr>
															<td>客户端</td>
															<td>broker</td>
															<td>队列</td>
															<td>broker偏移量</td>
															<td>消费者偏移量</td>
															<td>堆积量</td>
															<td>消费到</td>
														</tr>
													</thead>
													<tbody>
														<#list consumerProgressVO.offsetMap as k, v>
															<tr>
																<td id="${consumerProgressVO.consumer.id}_${k.brokerName}_${k.queueId}"></td>
																<td>${k.brokerName}</td>
																<td>${k.queueId}</td>
																<td>
																	${v.brokerOffset?string(",###")}
																</td>
																<td>
																	${v.consumerOffset?string(",###")}
																</td>
																<td>
																	${v.brokerOffset - v.consumerOffset}
																</td>
																<#if v.lastTimestamp <= 0>
									                    			<td data-toggle='tooltip' title="可能消息被删了">暂无</td>
									                    		<#else>
																	<td>
																		${v.lastTimestamp?number_to_datetime?string("yyyy-MM-dd HH:mm:ss")}
																	</td>
																</#if>
															</tr>
														</#list>
													</tbody>
												</table>
											</div>
										</div>
									</div> <!-- 详情结束 -->
									<!-- 跳过堆积 -->
									<div id="skipAccumulationModel${consumerProgressVO_index}" class="modal fade" tabindex="-1" aria-hidden="true">
										<div class="modal-dialog">
											<div class="modal-content">
												<div class="modal-header">
													<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
													<h4 class="modal-title"><b>确定跳过堆积的消息吗?</h4>
												</div>
												<form class="form-horizontal form-bordered form-row-stripped">
													<div class="modal-body">
														<div class="row">
															<div class="col-md-12">
																<div class="form-body">
																	<div class="form-group">
																		<label class="control-label col-md-3"> Topic: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.topic}" class="form-control" />
																		</div>
																	</div>
																	<div class="form-group">
																		<label class="control-label col-md-3"> 消费者: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.consumer.name}" class="form-control" />
																		</div>
																	</div>
																</div>
															</div>
														</div>
													</div>
													<div  class="modal-footer">
														<button type="button" data-dismiss="modal" class="btn" >取消</button>
														<button type="button" id="skipAccumulationBtn${consumerProgressVO_index}" class="btn btn-primary" onclick="skipAccumulation(${consumerProgressVO.consumer.tid},${consumerProgressVO.consumer.id},'skipAccumulationBtn${consumerProgressVO_index}')">确定</button>
													</div>
												</form>
											</div>
										</div>
									</div><!-- 跳过堆积结束 -->
									<!-- 消息回溯-->
									<div id="resetOffSetModel${consumerProgressVO_index}" class="modal fade" tabindex="-1" aria-hidden="true">
										<div class="modal-dialog">
											<div class="modal-content">
												<div class="modal-header">
													<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
													<h4 class="modal-title"><b>消息回溯</h4>
												</div>
												<form class="form-horizontal form-bordered form-row-stripped">
													<div class="modal-body">
														<div class="row">
															<div class="col-md-12">
																<div class="form-body">
																	<div class="form-group">
																		<label class="control-label col-md-3"> Topic: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.topic}" class="form-control" />
																		</div>
																	</div>
																	<div class="form-group">
																		<label class="control-label col-md-3"> 消费者: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.consumer.name}" class="form-control" />
																		</div>
																	</div>
																	<div class="form-group">
																		<label class="control-label col-md-3"> 回溯到: </label>
																		<div class="col-md-5">
																			<input type="text" id="resetOffsetDate${consumerProgressVO_index}" name="resetOffsetDate" class="Wdate form-control" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss',maxDate:'%y-%M-%d',minDate:'%y-%M-{%d-5}'})" style="width:100%;height:34px;cursor:pointer;" readonly="readonly">
																		</div>
																	</div>
																</div>
															</div>
														</div>
													</div>
													<div  class="modal-footer">
														<button type="button" data-dismiss="modal" class="btn" >取消</button>
														<button type="button" id="resetOffsetBtn${consumerProgressVO_index}" class="btn btn-primary" onclick="resetOffset(${consumerProgressVO_index},${consumerProgressVO.consumer.tid},${consumerProgressVO.consumer.id},'resetOffsetBtn${consumerProgressVO_index}')">确定</button>
													</div>
												</form>
											</div>
										</div>
									</div><!-- 消息回溯-->
									</#if>
									<!-- 删除consumer -->
									<div id="deleteConsumerModel${consumerProgressVO_index}" class="modal fade" tabindex="-1" aria-hidden="true">
										<div class="modal-dialog">
											<div class="modal-content">
												<div class="modal-header">
													<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
													<h4 class="modal-title"><b>确定删除消费者吗?</h4>
												</div>
												<form class="form-horizontal form-bordered form-row-stripped">
													<div class="modal-body">
														<div class="row">
															<div class="col-md-12">
																<div class="form-body">
																	<div class="form-group">
																		<label class="control-label col-md-3"> Topic: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.topic}" class="form-control" />
																		</div>
																	</div>
																	<div class="form-group">
																		<label class="control-label col-md-3"> 消费者: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.consumer.name}" class="form-control" />
																		</div>
																	</div>
																</div>
															</div>
														</div>
													</div>
													<div  class="modal-footer">
														<button type="button" data-dismiss="modal" class="btn" >取消</button>
														<button type="button" id="deleteConsumerBtn${consumerProgressVO_index}" class="btn btn-primary" onclick="deleteConsumer(${consumerProgressVO.consumer.tid},${consumerProgressVO.consumer.id},'deleteConsumerBtn${consumerProgressVO_index}')">确定</button>
													</div>
												</form>
											</div>
										</div>
									</div>
									<!-- 删除consumer-->
		                    	</td>
		                   	</tr>
						</#list>
						<!-- 广播模式 -->
						<#list resultExt.result as consumerProgressVO>
							<tr>
								<td>${consumerProgressVO_index + 1 + response.result?size}</td>
		                    	<td><a style="cursor:pointer" title="查看消费详情" data-target="#consumeDetailModel${consumerProgressVO_index}b" data-toggle="modal">${consumerProgressVO.consumer.name}</a></td>
		                    	<#if consumerProgressVO.ownerList??>
			                    	<td>
			                    		<#if consumerProgressVO.ownerList?seq_contains(userInfo.user) || userInfo.user.type == 1>
				                    		<#list consumerProgressVO.ownerList as user>
									    		<span onclick="prepareDeleteUserConsumer(${user.id},'${user.name!user.getEmailName()}',${consumerProgressVO.consumer.id})" data-toggle="tooltip" title="移除${user.name!user.getEmailName()}?" class="producer_delete pointer">${user.name!user.getEmailName()}</span>
						                    	<#if user_index + 1 lt consumerProgressVO.ownerList?size>
						                    		,
						                    	</#if>
				                    		</#list>
		                    				<span class="glyphicon glyphicon-plus-sign pointer" data-toggle="tooltip" title="授权其他用户查看${consumerProgressVO.consumer.name}?" onclick="associateUserConsumer(${consumerProgressVO.consumer.id},'${consumerProgressVO.consumer.name}')"></span>
		                    			<#else>
		                    				<#list consumerProgressVO.ownerList as user>
									    		<span class="pointer">${user.name!user.getEmailName()}</span>
						                    	<#if user_index + 1 lt consumerProgressVO.ownerList?size>
						                    		,
						                    	</#if>
				                    		</#list>
		                    			</#if>    		
			                    	</td>
		                    	<#else>
		                    		<td>暂无</td>
		                    	</#if>
	                    		<td>广播消费</td>
	                    		<td>${consumerProgressVO.diff}</td>
	                    		<td>${consumerProgressVO.consumeTpsFormat}</td>
	                    		<td>暂无</td>
		                    	<td>
		                    		<#if consumerProgressVO.offsetMap??>
<!-- 		                    		<button type="button" class="btn btn-info" data-target="#consumeDetailModel${consumerProgressVO_index}b" data-toggle="modal">详情</button>&nbsp; -->
		                    		<button title="跳过堆积的消息，直接消费至最新的消息" type="button" class="btn btn-success" data-target="#skipAccumulationModel${consumerProgressVO_index}b" data-toggle="modal">跳过堆积</button>&nbsp;
		                    		<button title="消费过去一段时间至现在的消息" type="button" class="btn btn-success" data-target="#resetOffSetModel${consumerProgressVO_index}b" data-toggle="modal">消息回溯</button>&nbsp;
		                    		</#if>
		                    		<button type="button" class="btn btn-warning" data-target="#deleteConsumerModel${consumerProgressVO_index}b" data-toggle="modal"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></button>&nbsp;
		                    		
		                    		<#if consumerProgressVO.offsetMap??>
		                    		<!-- 详情 -->
		                    		<div id="consumeDetailModel${consumerProgressVO_index}b" class="modal fade" tabindex="-1" aria-hidden="true">
										<div class="modal-dialog" style="width:700px">
											<div class="modal-content">
												<div class="modal-header">
													<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
													<h4 class="modal-title"><b>${consumerProgressVO.consumer.name}</b> 消费详情</h4>
												</div>
												<table class="table table-striped table-hover" style="margin-top: 0px">
													<thead>
														<tr>
															<td>clientId</td>
															<td>broker</td>
															<td>队列</td>
															<td>broker偏移量</td>
															<td>消费者偏移量</td>
															<td>堆积量</td>
														</tr>
													</thead>
													<tbody>
														<#list consumerProgressVO.consumeStatsList as consumeStats>
															<tr>
																<td rowspan=${consumeStats.offsetTable?size+1}>${consumeStats.clientId}</td>
															</tr>
															<#list consumeStats.offsetTable as mq,offset>
															<tr>
																<td>${mq.brokerName}</td>
																<td>${mq.queueId}</td>
																<td>
																	${offset.brokerOffset?string(",###")}
																</td>
																<td>
																	${offset.consumerOffset?string(",###")}
																</td>
																<td>
																	${offset.brokerOffset - offset.consumerOffset}
																</td>
															</tr>
															</#list>
														</#list>
													</tbody>
												</table>
											</div>
										</div>
									</div> <!-- 详情结束 -->
									<!-- 跳过堆积 -->
									<div id="skipAccumulationModel${consumerProgressVO_index}b" class="modal fade" tabindex="-1" aria-hidden="true">
										<div class="modal-dialog">
											<div class="modal-content">
												<div class="modal-header">
													<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
													<h4 class="modal-title"><b>确定跳过堆积的消息吗?</h4>
												</div>
												<form class="form-horizontal form-bordered form-row-stripped">
													<div class="modal-body">
														<div class="row">
															<div class="col-md-12">
																<div class="form-body">
																	<div class="form-group">
																		<label class="control-label col-md-3"> Topic: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.topic}" class="form-control" />
																		</div>
																	</div>
																	<div class="form-group">
																		<label class="control-label col-md-3"> 消费者: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.consumer.name}" class="form-control" />
																		</div>
																	</div>
																</div>
															</div>
														</div>
													</div>
													<div  class="modal-footer">
														<button type="button" data-dismiss="modal" class="btn" >取消</button>
														<button type="button" id="skipAccumulationBtn${consumerProgressVO_index}b" class="btn btn-primary" onclick="skipAccumulation(${consumerProgressVO.consumer.tid},${consumerProgressVO.consumer.id},'skipAccumulationBtn${consumerProgressVO_index}b')">确定</button>
													</div>
												</form>
											</div>
										</div>
									</div><!-- 跳过堆积结束 -->
									<!-- 消息回溯-->
									<div id="resetOffSetModel${consumerProgressVO_index}b" class="modal fade" tabindex="-1" aria-hidden="true">
										<div class="modal-dialog">
											<div class="modal-content">
												<div class="modal-header">
													<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
													<h4 class="modal-title"><b>消息回溯</h4>
												</div>
												<form class="form-horizontal form-bordered form-row-stripped">
													<div class="modal-body">
														<div class="row">
															<div class="col-md-12">
																<div class="form-body">
																	<div class="form-group">
																		<label class="control-label col-md-3"> Topic: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.topic}" class="form-control" />
																		</div>
																	</div>
																	<div class="form-group">
																		<label class="control-label col-md-3"> 消费者: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.consumer.name}" class="form-control" />
																		</div>
																	</div>
																	<div class="form-group">
																		<label class="control-label col-md-3"> 回溯到: </label>
																		<div class="col-md-5">
																			<input type="text" id="resetOffsetDate${consumerProgressVO_index}b" name="resetOffsetDate" class="Wdate form-control" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss',maxDate:'%y-%M-%d',minDate:'%y-%M-{%d-5}'})" style="width:100%;height:34px;cursor:pointer;" readonly="readonly">
																		</div>
																	</div>
																</div>
															</div>
														</div>
													</div>
													<div  class="modal-footer">
														<button type="button" data-dismiss="modal" class="btn" >取消</button>
														<button type="button" id="resetOffsetBtn${consumerProgressVO_index}b" class="btn btn-primary" onclick="resetOffset('${consumerProgressVO_index}b',${consumerProgressVO.consumer.tid},${consumerProgressVO.consumer.id},'resetOffsetBtn${consumerProgressVO_index}b')">确定</button>
													</div>
												</form>
											</div>
										</div>
									</div><!-- 消息回溯-->
									</#if>
									<!-- 删除consumer -->
									<div id="deleteConsumerModel${consumerProgressVO_index}b" class="modal fade" tabindex="-1" aria-hidden="true">
										<div class="modal-dialog">
											<div class="modal-content">
												<div class="modal-header">
													<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
													<h4 class="modal-title"><b>确定删除消费者吗?</h4>
												</div>
												<form class="form-horizontal form-bordered form-row-stripped">
													<div class="modal-body">
														<div class="row">
															<div class="col-md-12">
																<div class="form-body">
																	<div class="form-group">
																		<label class="control-label col-md-3"> Topic: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.topic}" class="form-control" />
																		</div>
																	</div>
																	<div class="form-group">
																		<label class="control-label col-md-3"> 消费者: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.consumer.name}" class="form-control" />
																		</div>
																	</div>
																</div>
															</div>
														</div>
													</div>
													<div  class="modal-footer">
														<button type="button" data-dismiss="modal" class="btn" >取消</button>
														<button type="button" id="deleteConsumerBtn${consumerProgressVO_index}b" class="btn btn-primary" onclick="deleteConsumer(${consumerProgressVO.consumer.tid},${consumerProgressVO.consumer.id},'deleteConsumerBtn${consumerProgressVO_index}b')">确定</button>
													</div>
												</form>
											</div>
										</div>
									</div>
									<!-- 删除consumer-->
		                    	</td>
		                   	</tr>
						</#list>
					</#if>
                </tbody>
           </table>
    </div>
</div>
<!-- 提示弹窗 -->
<div class="modal fade" id="deleteUserConsumerModal" aria-hidden="true">  
  <div class="modal-dialog">  
    <div class="modal-content message_align">  
      <div class="modal-header">  
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>  
        <h4 class="modal-title">确定要移除用户吗？</h4>  
      </div>  
		<form class="form-horizontal form-bordered form-row-stripped">
			<div class="modal-body">
				<div class="row">
					<!-- 控件开始 -->
					<div class="col-md-12">
						<!-- form-body开始 -->
						<div class="form-body">
							<div class="form-group">
								<label class="control-label col-md-3"> 用户: </label>
								<div class="col-md-5">
									<input type="text" id="user_name" class="form-control" readonly="readonly"/>
									<input type="hidden" id="currentUid"/>
									<input type="hidden" id="currentCid"/>
								</div>
							</div>						
						</div>
						<!-- form-body 结束 -->
					</div>
					<div id="info"></div>
					<!-- 控件结束 -->
				</div>
			</div>
			
			<div class="modal-footer">
				<button type="button" data-dismiss="modal" class="btn" >取消</button>
				<button type="button" id="deleteUserConsumerBtn" onclick="deleteUserConsumer()" class="btn btn-primary">确定</button>
			</div>
		
		</form>
    </div>
  </div>
</div>
<div id="addUserConsumerModal" class="modal fade" tabindex="-1" data-width="400">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title">授权其他用户</h4>
			</div>
			<form class="form-horizontal form-bordered form-row-stripped" id="addUserProducerModalForm">
				<div class="modal-body">
					<div class="row">
						<div class="col-md-12">
							<div class="form-body">
								<div class="form-group">
									<label class="control-label col-md-3"> Topic: </label>
									<div class="col-md-5">
										<input type="text" id="topicName" readonly="readonly" class="form-control"/>
									</div>
								</div>
								<div id="consumerGroup" class="form-group">
									<label class="control-label col-md-3"> 消费者: </label>
									<div class="col-md-5">
										<input type="text" id="consumerGroupName" readonly="readonly" class="form-control" />
										<input type="hidden" id="consumerGroupID"/>
									</div>
								</div>
								<div class="form-group">
									<label class="control-label col-md-3"> 选择用户: </label>
							        <div class="col-md-5">
			    						<select id="user_search_select" class="selectpicker" title="请选择" data-live-search-placeholder="搜索" data-live-search="true"></select> 	  			
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" data-dismiss="modal" class="btn" >取消</button>
					<button type="button" class="btn btn-primary" id="associateUserConsumerBtn" onclick="addUserCounsumerRelationship()">确定</button>
				</div>
			</form>
		</div>
	</div>
</div>
<!-- 准备搜索部分 -->
<div class="row">
<div class="col-md-12">
	<div class="border-top"></div>
	<div style="float:left;margin:10px 5px;"><h5><b>${topic.name}</b> 消费流量图</h5></div>
	<div id="consume_search" style="float:right;margin:10px 0px;"></div>
</div>
</div>
<!-- 准备曲线图 -->
<div id="consume_lineChart"><center>暂无数据</center></div>

<!-- 偏移量消息搜索 -->
<div id="offsetMsgSearchModal" class="modal fade" tabindex="-1">
	<div class="modal-dialog" style="width:700px">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" onclick="hideOffsetMsgSearchModal()" aria-hidden="true">&times;</button>
				<h4 class="modal-title">消息查询</h4>
			</div>
			<div class="modal-body">
				<div style="float:right;margin:0px 0px 10px 0px;">
					<form class="form-inline" id="offsetMsgSearchForm">
						<div>
							<!-- 偏移量查询 -->
							<div class="form-group">
								<label for="toStart"> 起始偏移量: </label>
								<input id="toStart" name="toStart" type="text" class="form-control" style="width:120px;" placeholder="broker最小偏移量">
							</div>
							<div class="form-group">
					  			<label for="toEnd"> 结束偏移量: </label>
								<input id="toEnd" name="toEnd" type="text" class="form-control" style="width:120px;" placeholder="broker最大偏移量">
							</div>
							<div class="form-group">
					    	    <input type="text" class="form-control" id="toKey" name="toKey" style="width:150px;" placeholder="关键字">
					  	    </div>
							<input type="hidden" id="toCid" name="toCid" value="${topic.clusterId}">
		  	    			<input type="hidden" id="toTopic" name="toTopic" value="">
		  	    			<input type="hidden" id="toMessageParam" name="toMessageParam">
		  	    			<input type="hidden" id="toAppend" name="toAppend" value="false">
		  	    			<button type="button" onclick="showMoreSearchCondition()" class="btn" data-toggle="tooltip" title="单击展开更多搜索项"><span class="glyphicon glyphicon-filter" aria-hidden="true"></span></button>
							<button type="button" onclick="searchOffsetMessage(false)" class="btn btn-search time"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button>
						</div>
						<div class="form-group hide" id ="moreSearchCondition" style="margin-top:10px">
							<label style="margin-left:23px"> broker: </label>
							<select id="brokerNameSearchSelect" class="selectpicker" name="toBrokerName" onchange="brokerNameSelectChange(this)"></select>
							<label style="margin-left:27px"> queue: </label>
							<select id="queueSearchSelect" class="selectpicker" name="toQueue" onchange="queueSelectChange(this)">
							<option value="-1">全部</option>
							</select>
						</div>	
					</form>
				</div>
				<table id="offsetDataTable" class="table table-striped table-hover" style="margin-top: 0px;word-break:break-all; word-wrap:break-all;">
					<colgroup>
						<col width="50px">
						<col width="110px">
						<col width="190px">
						<col width="50px">
						<col>
					</colgroup>
					<thead>
						<tr>
							<td>序号</td>
							<td>客户端</td>
							<td>发送时间</td>
							<td data-toggle="tooltip" title="重试次数">重试</td>
							<td>消息</td>
						</tr>
					</thead>
					<tbody>
						<tr class="no_more_data"><td colspan=5 class="text-center">暂无数据</td></tr>
					</tbody>
				</table>
				<ul class="pager" id="offsetPager" style="display:none;">
					<li id="offsetPrevious" class="previous" onclick="offsetPrevious()"><a href="javascript:void(0)">&larr; 上一页</a></li>
					<li><a href="#">第<b id="offsetPageNum"></b>页，命中数：<b id="offsetSizeNum"></b>，检索数：<b id="offsetSearchNum"></b>，预估剩余数：<b id="offsetLeftNum"></b></a></li>
					<li id="offsetNext" class="next" onclick="offsetNext()"><a href="javascript:void(0)">下一页 &rarr;</a></li>
				</ul>
			</div>
		</div>
	</div>
</div>

<script>
<#if response.OK>
$(function() {
	lineChart("consume", function (){
		$("#tid").val("${RequestParameters.tid}");
	});
});
</#if>
</script>

<script>
/**
 * 跳过堆积
 */
function skipAccumulation(tid, cid, btn){
	disable(btn);
	$.get('${request.contextPath}/consumer/reset/offset',{
		tid: tid,
		consumerId: cid,
		cid: $("#toCid").val()
	},function(data){
        if(data.status == 200){
			toastr.success(data.message);  
			modalHide(3000);
	    }else{
	    	toastr.error("操作失败！"+data.message);  
	    	enable(btn);
	    }
    }, 'json');
}
/**
 * 重置偏移量
 */
function resetOffset(idx, tid, cid, btn){
	var resetOffsetTo = $("#resetOffsetDate"+idx).val();
	if(!resetOffsetTo){
		alert("请选择回溯到的时间!");
		return;
	}
	disable(btn);
	$.get('${request.contextPath}/consumer/reset/offset',{
		tid: tid,
		consumerId: cid,
		offset: resetOffsetTo,
		cid: $("#toCid").val()
	},function(data){
        if(data.status == 200){
			toastr.success(data.message);  
			modalHide(3000);
	    }else{
	    	toastr.error("操作失败！"+data.message);  
	    	enable(btn);
	    }
    }, 'json');
}
/**
 * 删除消费者
 */
function deleteConsumer(tid, cid, btn){
	disable(btn);
	$.post('${request.contextPath}/consumer/delete',{
		tid: tid,
		consumerId: cid
	},
    function(data){
        if(data.status == 200){
			toastr.success("删除消费者申请成功");  
			modalHide(3000);
	    }else{
	    	toastr.error("操作失败！"+data.message);  
	    	enable(btn);
	    }
    }, 'json');
}

$(function(){
	$("[data-toggle='tooltip']").tooltip({container: 'body'});
	$("[data-toggle='modal']").tooltip({container: 'body'});
	 //添加删除特效
    $(".producer_delete").hover(function(){
    	$(this).addClass("delete");
    },function(){
    	$(this).removeClass("delete");
    });
 	// 初始化user列表
	initUserList('user_search_select');
	$(".selectpicker").selectpicker({
		width : 120
 	});
});
//准备删除
function prepareDeleteUserConsumer(uid,userName,consumerID){
	$("#user_name").val(userName);
	$("#currentUid").val(uid);
	$("#currentCid").val(consumerID);
	$("#deleteUserConsumerModal").modal('show');
}
//删除用户与消费者关联
function deleteUserConsumer(){
	disable("deleteUserConsumerBtn");
	$.post('${request.contextPath}/userConsumer/delete',
		{
			uid: $("#currentUid").val(),
			cid: $("#currentCid").val()
		},
        function(data){
            if(data.status == 200){
            	toastr.success("申请成功！请耐心等待！");  	            	
            	reload(1000);            	
		    }else{
		    	toastr.error("删除失败！"+data.message);  
		    	enable("deleteUserConsumerBtn");
		    }
    }, 'json');
}
/**
 * 初始化user下拉列表
 */
function initUserList(componentId){
	$.get('${request.contextPath}/user/list',
	        function(data){
	            if(data.status == 200){
	            	var content = "";
	            	for(var i in data.result){
	            		var user = data.result[i];
	            		var value = user.email.substring(0, user.email.indexOf("@"));
	            		if(user.name && user.name != value){
	            			value = user.name + "【" + value +"】";
	            		}
	            		content += "<option value='"+user.id+"'>"+value+"</option>";	
	            	}
	        		$("#"+componentId).html(content);
	        		$("#"+componentId).selectpicker('refresh');
			    }else{
			    	toastr.error("数据获取失败！"+data.message);  
			    }
        }, 'json');
}
//关联用户
function associateUserConsumer(consumerGroupID,consumerGroupName){
	$("#topicName").val('${topic.name}');
	$("#consumerGroupName").val(consumerGroupName);
	$("#consumerGroupID").val(consumerGroupID);
	$("#addUserConsumerModal").modal('show');
}
/**
 * 发送添加用户请求
 */
function addUserCounsumerRelationship(){
	if(!$("#user_search_select").val()){
		alert("请先选择用户");
		return;
	}
	disable("associateUserConsumerBtn");
	$.post('${request.contextPath}/consumer/auth/associate',
			{
				cid: $("#consumerGroupID").val(),
				tid: $("#tid").val(),
				uid: $('#user_search_select option:selected').val(),
			},
	        function(data){
	            if(data.status == 200){
	            	toastr.success("申请成功！请耐心等待！");  	            	
	            	reload(1000);            	
			    }else{
			    	toastr.error("申请失败！"+data.message);  
			    	enable("associateUserConsumerBtn");
			    }
	    }, 'json');
}

function hideOffsetMsgSearchModal(){
	$('#offsetMsgSearchModal').modal('hide');
}
//当前消息搜索时的topic
var currentSelectTopic = '';
var queueOffsetMap = null;
function brokerNameSelectChange(obj){
	var value = obj.options[obj.selectedIndex].value;
	if (value == "all"){
		$("#queueSearchSelect").html("<option value='-1'>全部</option>");
		$("#queueSearchSelect").selectpicker('refresh');
		$("#toStart").val(minAllOffset);
		$("#toEnd").val(maxAllOffset);
		return;
	}
	resetMaxOffsetByBrokerName(value);
	$.get('${request.contextPath}/consumer/broker/queue',
			{
				topic: currentSelectTopic,
				brokerName: value,
				clusterId : $("#toCid").val()
			},
	        function(data){
	            if(data.status == 200){
	            	queueOffsetMap = data.result;
	            	var content = "<option value='-1'>全部</option>";
	            	for (var  key in queueOffsetMap){
	            		content += "<option value='"+key+"'>"+key+"</option>";
	            	}
	            	$("#queueSearchSelect").html(content);
	            	$("#queueSearchSelect").selectpicker('refresh');
			    }
	    }, 'json');
}
var maxAllOffset = '';
var minAllOffset = '';
function initOffsetMsgModal(type, index, topic, maxOffset){
	// 清空数据
	$("#offsetDataTable tbody").html("<tr class='no_more_data'><td colspan=5 class='text-center'>暂无数据</td></tr>");
	$("#offsetDataTable input").remove();
	$("#toTopic").val(topic);
	$("#offsetPager").hide();
	
	// 计算offset
	var start = maxOffset - 100;
	if(start < 0){
		start = 0;
	}
	maxAllOffset = maxOffset;
	minAllOffset = start;
	currentSelectTopic = topic;
	$("#toStart").val(start);
	$("#toEnd").val(maxOffset);
	$("#toKey").val("");
	//初始化broker列表
 	initBrokerList('brokerNameSearchSelect');
 	$("#queueSearchSelect").selectpicker('refresh');
}
//显示搜索条件broker和队列
function showMoreSearchCondition(){
	if ($("#moreSearchCondition").hasClass('hide')){
		$("#moreSearchCondition").removeClass('hide');
	} else {
		$("#moreSearchCondition").addClass('hide');
		//重置broker下拉框状态
		document.getElementById("brokerNameSearchSelect").options.selectedIndex = 0; //回到初始状态
	    $("#brokerNameSearchSelect").selectpicker('refresh');
	}
}
//偏移量消息搜索
function searchOffsetMessage(append){
	$("#toAppend").val(append);
	post('${request.contextPath}/msg/topic/offset/search', $("#offsetMsgSearchForm").serialize(), function(data){
		if(!append){
			$("#offsetDataTable tbody").remove();
			$("#offsetDataTable input").remove();
		}
       	$("#offsetDataTable").append(data);
    });
}

var offsetPageNum = 0;
//显示分页
function showOffsetPage(num){
	offsetPageNum = num;
	var comp = $("#offsetData_"+num);
	var size = comp.attr("data_size");
	var search = comp.attr("data_search");
	var left = comp.attr("data_left");
	$("#offsetPageNum").html(num);
	$("#offsetSizeNum").html(size);
	$("#offsetSearchNum").html(search);
	$("#offsetLeftNum").html(left);
	$("#offsetPager").show();
	if(num == 1){
		$("#offsetPrevious").addClass("disabled");
	} else {
		$("#offsetPrevious").removeClass("disabled");
	}
	if(left > 0){
		$("#offsetNext").removeClass("disabled");
	} else {
		$("#offsetNext").addClass("disabled");
	}
	// 展示数据
	$("#offsetPage_"+offsetPageNum).show().siblings("tbody").hide();
}
//上一页
function offsetPrevious(){
	if(!$("#offsetPrevious").hasClass("disabled")){
		showOffsetPage(offsetPageNum - 1);
	}
}
//下一页
function offsetNext(){
	if(!$("#offsetNext").hasClass("disabled")){
		if($("#offsetData_"+(offsetPageNum+1)).length > 0){
			showOffsetPage(offsetPageNum+1);
		} else {
			searchOffsetMessage(true);
		}
	}
}
/**
 * 初始化broker下拉列表
 */
var brokerNameMap = null;
function initBrokerList(componentId){
	$.get('${request.contextPath}/topic/brokerName/list',
			{
				topic: currentSelectTopic,
				clusterId : $("#toCid").val()
			},
	        function(data){
	            if(data.status == 200){
	            	brokerNameMap = data.result;
	            	var content = "<option value='all'>全部</option>";
	            	for (var key in brokerNameMap){
	            		content += "<option value='"+key+"'>"+key+"</option>";
	            	}
	        		$("#"+componentId).html(content);
	        		$("#"+componentId).selectpicker('refresh');
			    }else{
			    	toastr.error("数据获取失败！"+data.message);  
			    }
        }, 'json');
}
function queueSelectChange(obj){
	var value = obj.options[obj.selectedIndex].value;
	var queue = parseInt(value);
	if (queue == -1){
		resetMaxOffsetByBrokerName($("#brokerNameSearchSelect").val());
		return;
	}
	resetMaxOffset(queue, 'queue');
}
//重置偏移量
function resetMaxOffsetByBrokerName(key){
	if (brokerNameMap != null){
		resetMaxOffset(key,'broker');
	}
}
function resetMaxOffset(key,type){
	var max = null;
	if (type == 'broker'){
		max = brokerNameMap[key];
	}else{
		max = queueOffsetMap[key];
	}
	
	var min = max - 100;
	if (min < 0){
		min = 0;
	}
	$("#toStart").val(min);
	$("#toEnd").val(max);
}

// 获取队列客户端ip
var queueOwnerInitArray = new Array();
function getQueueOwner(consumer, consumerId){
	if(queueOwnerInitArray[consumerId]){
		return;
	}
	$.get('${request.contextPath}/consumer/queue/owner',{
		cid: $("#toCid").val(),
		consumer: consumer
	},function(data){
        if(data.status == 200){
        	for(var i in data.result){
        		var id = "#" + consumerId + "_" + data.result[i].brokerName + "_" + data.result[i].queueId;
        		var prevContent = $(id).html();
        		if(prevContent){
        			prevContent += ","
        		}
	        	$(id).html(prevContent + data.result[i].clientId);
        	}
	    }else{
	    	toastr.error("获取客户端失败！"+data.message);  
	    }
        queueOwnerInitArray[consumerId] = true;
    }, 'json');
}
</script>